<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <link rel="stylesheet" href="${ctx}/statics/css/update.css">
    <link rel="stylesheet" href="${ctx}/statics/css/common.css">
    <script type="text/javascript" src="${ctx}/appjs/acct/acctBank.js"></script>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>分销商列表</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>收款账户</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

    var has_add = '';
    var has_edit = '';
    var has_delete = '';
</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="col-sm-12">
        <div class="ibox">
            <div class="ibox-body">
                <div class="row">
                    <input type="hidden" name="tenantOperatorCode" id="tenantOperatorCode"
                           value="${tenantOperatorCode}">
                    <%--<input id="acctBankAccount" name="acctBankAccount" type="text"--%>
                    <%--class="form-control shortInput input-distance"--%>
                    <%--placeholder="卡号信息">--%>
                    <%--<input id="acctBank" name="acctBank" type="text" class="form-control shortInput input-distance"--%>
                    <%--placeholder="银行名称">--%>
                    <%--<button class="btn btn-success input-distance" onclick="acctBank.reLoad()">查询</button>--%>
                    <span class="before-but"
                          style="display: inline-block;font-size: 0.1rem;font-weight: bolder;padding: 3px 40px;">收款账户</span>
                    <button  type="button" class="btn btn-primary"
                            onclick="acctBank.addAcctBank()">
                        新增
                    </button>

                    <%--  新增银行卡信息模态框  --%>
                    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog"
                         aria-labelledby="exampleModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                            aria-hidden="true"></span></button>
                                    <h4 class="modal-title" id="exampleModalLabel" data-dismiss="modal"
                                        aria-label="Close">
                                        关闭</h4>
                                </div>
                                <div class="modal-body">
                                    <form id="contentForm" class="layui-form">
                                        <input type="hidden" name="acctBankId" id="acctBankId">
                                        <input type="hidden" name="tenantOperatorCode"
                                               value="${tenantOperatorCode}">
                                        <div class="form-group">
                                            <label class="col-sm-3 col-form-label text-right">账户类型:</label>
                                            <input type="radio" class="form-control bankCard" name="withdrawType"
                                                   lay-filter="withdrawType" checked
                                                   title="银行卡" value="1">
                                            <input type="radio" class="form-control zfb" name="withdrawType"
                                                   lay-filter="withdrawType"
                                                   title="支付宝" value="0">
                                        </div>
                                        <div class="form-group bankDiv">
                                            <label class="col-sm-3 col-form-label text-right">开户银行:</label>
                                            <input id="bank" name="bank">
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 col-form-label text-right">账户号码:</label>
                                            <input id="accountNumber" name="accountNumber">
                                        </div>
                                        <div class="form-group acctBankCodeDiv">
                                            <label class="col-sm-3 col-form-label text-right">所属银行:</label>
                                            <select class="form-control acctBankCode" id="acctBankCode"
                                                    name="acctBankCode">
                                                <%--<option value="">选择银行</option>--%>
                                                <option value="1002">工商银行</option>
                                                <option value="4025">广州农村商业银行</option>
                                                <option value="4026">佛山农商银行</option>
                                                <option value="4027">东莞农村商业银行</option>
                                                <option value="4028">九江银行股份有限公司</option>
                                                <option value="1005">农业银行</option>
                                                <option value="1003">建设银行</option>
                                                <option value="1026">中国银行</option>
                                                <option value="1020">交通银行</option>
                                                <option value="1001">招商银行</option>
                                                <option value="1066">邮储银行</option>
                                                <option value="1006">民生银行</option>
                                                <option value="1010">平安银行</option>
                                                <option value="1021">中信银行</option>
                                                <option value="1004">浦发银行</option>
                                                <option value="1009">兴业银行</option>
                                                <option value="1022">光大银行</option>
                                                <option value="1027">广发银行</option>
                                                <option value="1025">华夏银行</option>
                                                <option value="1056">宁波银行</option>
                                                <option value="4836">北京银行</option>
                                                <option value="1024">上海银行</option>
                                                <option value="1054">南京银行</option>
                                                <option value="4755">长子县融汇村镇银行</option>
                                                <option value="4216">长沙银行</option>
                                                <option value="4051">浙江泰隆商业银行</option>
                                                <option value="4753">中原银行</option>
                                                <option value="4761">企业银行（中国）</option>
                                                <option value="4036">顺德农商银行</option>
                                                <option value="4752">衡水银行</option>
                                                <option value="4756">长治银行</option>
                                                <option value="4767">大同银行</option>
                                                <option value="4115">河南省农村信用社</option>
                                                <option value="4150">宁夏黄河农村商业银行</option>
                                                <option value="4156">山西省农村信用社</option>
                                                <option value="4166">安徽省农村信用社</option>
                                                <option value="4157">甘肃省农村信用社</option>
                                                <option value="4153">天津农村商业银行</option>
                                                <option value="4113">广西壮族自治区农村信用社</option>
                                                <option value="4108">陕西省农村信用社</option>
                                                <option value="4076">深圳农村商业银行</option>
                                                <option value="4052">宁波鄞州农村商业银行</option>
                                                <option value="4764">浙江省农村信用社联合社</option>
                                                <option value="4217">江苏省农村信用社联合社</option>
                                                <option value="4072">江苏紫金农村商业银行股份有限公司</option>
                                                <option value="4769">北京中关村银行股份有限公司</option>
                                                <option value="4778">星展银行（中国）有限公司</option>
                                                <option value="4766">枣庄银行股份有限公司</option>
                                                <option value="4758">海口联合农村商业银行股份有限公司</option>
                                                <option value="4763">南洋商业银行（中国）有限公司</option>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 col-form-label text-right">账户名称:</label>
                                            <input id="userName" name="userName">
                                        </div>

                                    </form>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    <button type="button" class="btn btn-success" id="addAcctBank">添加
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <table id="exampleTable" data-mobile-responsive="true" class="serda">
                </table>
                <form class="ex_form" style="margin-top: 10px;">
                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label "
                               style="font-weight: bolder;font-size: 18px;">结算相关</label>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-1 col-form-label ">自动推送账单</label>
                        <div class="col-sm-6" style="display: flex;align-items: center; flex-direction: row ">
                            <input type="radio" class="form-control" name="showPlaceType1" id="pushMethod1"
                                   lay-filter="transferType"
                                   title="开启" value="1">开启
                            <input type="radio" class="form-control form-const" name="showPlaceType1" id="pushMethod2"
                                   lay-filter="transferType" checked="true"
                                   title="关闭" value="0">关闭

                            <%--                            <span style="color: #666666;display:inline-block;verticle-align:middle;">置顶只能存在最新的一条，设置后旧置顶会被替换。</span>--%>

                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-1 col-form-label">提现上传发票</label>
                        <div class="col-sm-6" style="display: flex;align-items: center; flex-direction: row ">
                            <input type="radio" class="form-control" name="showPlaceType2" id="uplaodInvoice1"
                                   lay-filter="transferType"
                                   title="开启" value="0">开启
                            <input type="radio" class="form-control form-const" name="showPlaceType2"
                                   id="uplaodInvoice2"
                                   lay-filter="transferType" checked="true"
                                   title="关闭" value="1">关闭

                            <%--                            <span style="color: #666666;display:inline-block;verticle-align:middle;">置顶只能存在最新的一条，设置后旧置顶会被替换。</span>--%>

                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-1 col-form-label">结算转账方式</label>
                        <div class="col-sm-6" style="display: flex;align-items: center; flex-direction: row ">
                            <input type="radio" class="form-control" name="showPlaceType3" id="transferMethod1"
                                   lay-filter="transferType"
                                   title="是" value="0">线上
                            <input type="radio" class="form-control form-const" name="showPlaceType3"
                                   id="transferMethod2"
                                   lay-filter="transferType" checked="true"
                                   title="否" value="1">线下

                            <%--                            <span style="color: #666666;display:inline-block;verticle-align:middle;">置顶只能存在最新的一条，设置后旧置顶会被替换。</span>--%>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-1 col-form-label">自动提现审核</label>
                        <div class="col-sm-6" style="display: flex;align-items: center; flex-direction: row ">
                            <input type="radio" class="form-control" name="showPlaceType4" id="withdrawAudit1"
                                   lay-filter="transferType"
                                   title="是" value="1">开启
                            <input type="radio" class="form-control form-const" name="showPlaceType4"
                                   id="withdrawAudit2"
                                   lay-filter="transferType" checked="true"
                                   title="否" value="0">关闭

                            <%--                            <span style="color: #666666;display:inline-block;verticle-align:middle;">置顶只能存在最新的一条，设置后旧置顶会被替换。</span>--%>

                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-fo rm-label" style="margin-left: 1%;">设置分销商提现手续费</label>
                        <%--                        <div class="col-sm-6" style="display: flex;align-items: center; flex-direction: row ">--%>
                        <div class="col-sm-6">
                            <input type="number" class="form-control color-change" id="typeName" name="title"
                                   step="0.01"
                                   placeholder=""
                                   style="display: inline-block;margin-right: 5px;width: 15% !important;height: 29px !important;">元
                        </div>
                        <%--                        </div>--%>
                    </div>
                    <div class="form-group row">
                        <div class="col-sm-3 col-sm-offset-8 ">
                            <button id="subnew" type="submit" class="btn btn-primary" onclick="subon()">提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
// $(function () {
//     // alert($("input[name='withdrawType']:checked").val());
//     if ($("input[name='withdrawType']:checked").val() == "0") {
//         // console.log(99);
//         $(".bankDiv").addClass("hide");
//         $(".acctBankCodeDiv").addClass("hide");
//     } else {
//         // console.log(123);
//         $(".bankDiv").removeClass("hide");
//         $(".acctBankCodeDiv").removeClass("hide");
//     }
// })

    layui.use(['form', 'jquery', 'tree', 'laydate', 'util'], function () {

        var form = layui.form;
        var $ = layui.jquery;

        form.on("radio(withdrawType)", function (data) {
            if ($(this).val() == "0") {
                $(".bankDiv").addClass("hide");
                $(".acctBankCodeDiv").addClass("hide");
            } else {
                $(".bankDiv").removeClass("hide");
                $(".acctBankCodeDiv").removeClass("hide");
            }
        });



    })

    acctBank.init();
</script>
</body>
<script>
    // $(".serda").parent('.fixed-table-body').css('height','50% !important');
    function subon() {

        let tenantOperatorCode = $('#tenantOperatorCode').val();
        let withdrawServiceCharge = $('#typeName').val();
        if (withdrawServiceCharge < 0) {
            alert("提现手续费需大于0元");
            return false;
        }
        let withdrawAudit = $("input[name='showPlaceType4']:checked").val();
        let transferMethod = $("input[name='showPlaceType3']:checked").val();
        let uploadInvoice = $("input[name='showPlaceType2']:checked").val();
        let pushMethod = $("input[name='showPlaceType1']:checked").val();
        var obj = {
            tenantOperatorCode: tenantOperatorCode,
            withdrawServiceCharge: withdrawServiceCharge,
            withdrawAudit: withdrawAudit,
            transferMethod: transferMethod,
            uploadInvoice: uploadInvoice,
            pushMethod: pushMethod,

        };
        $.ajax({
            type: "POST",
            url: prefix + "/saveTenantOperatorAcctSetting",
            // data: JSON.stringify(obj),
            data: obj,
            async: false,
            success: function (data) {
                parent.layer.msg("操作成功");
                // reLoad();
            },
            error: function () {

                parent.layer.msg("操作失败");
            }
        });

    }

    getTenantOperatorAcctSetting();

    function getTenantOperatorAcctSetting() {
        $.ajax({
            type: "get",
            url: prefix + "/selectTenantOperatorAcctSetting",
            data: {
                tenantOperatorCode: $("#tenantOperatorCode").val(),
            },
            success: function (data) {
                if (data.data != null && data.data != '') {
                    $("input[name='showPlaceType1'][value=" + data.data.pushMethod + "]").prop("checked", "checked");
                    $("input[name='showPlaceType2'][value=" + data.data.uploadInvoice + "]").prop("checked", "checked");
                    $("input[name='showPlaceType3'][value=" + data.data.transferMethod + "]").prop("checked", "checked");
                    $("input[name='showPlaceType4'][value=" + data.data.withdrawAudit + "]").prop("checked", "checked");
                    $("#typeName").val(data.data.withdrawServiceCharge);
                } else {
                    $("#pushMethod2").prop("checked", true);
                    $("#uplaodInvoice2").prop("checked", true);
                    $("#transferMethod2").prop("checked", true);
                    $("#withdrawAudit2").prop("checked", true);
                }
            }
        });
    }
</script>
</html>